package week2;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Demo {

    @Test
    public void t1(){
        Cal add = new Add(5,7);
        int result = add.result();
        System.out.println(result);
         add = new Sub(8,3);
    }

    @Test
    public void t2(){
        int max = MathUtil.max(7,9,1);
        System.out.println(max);
        int max1 = Math.max(8,16165646);
        int next = MathUtil.nextInt(15);
        System.out.println(next);
    }

    @Test
    public void t3(){
        int[] array1 = new int[]{9,70,18,659,88,6669,665,26663};
        int max = ArrayUtil.max(array1);
        System.out.println(max);
    }

    @Test
    public void t4(){
        StringTest1 stringTest1 = new StringTest1();
        String smallSpell = stringTest1.toLowerCase("I Love Java");
        System.out.println(smallSpell);

    }


    //使用String类中的split()函数，统计出“this is my homework! I must finish it!”中单词的个数。
    //（注意：单词之间用一个空格来分隔。）
    @Test
    public void t5(){
        String str = "this is my homework! I must finish it!";
        String[] array = str.split(" ");
        for(String word : array){
            boolean isZiMu = true;
            char[] arr = word.toCharArray();
            char[] arr1 = new char[word.length() - 1];
            for (int i = 0; i < arr.length; i++){
                if((arr[i] >= 'A' && arr[i] <= 'Z') || (arr[i] >= 'a' && arr[i] <= 'z')){
                } else {
                    isZiMu = false;
                }
            }
            if(isZiMu == false){
                for (int j = 0; j < arr1.length; j++){
                    arr1[j] = arr[j];
                }
                word = String.valueOf(arr1);
            }
            System.out.println(word);
        }
    }

    @Test
    public void t123(){

        try {
            FileInputStream fileInputStream = new FileInputStream("ja.txt");
            //FileNotFoundException fileNotFoundException = new FileNotFoundException();
            //FileNotFoundException e = fileNotFoundException;
            fileInputStream.read();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {

        }

    }


}
